package com.ulife.item.module.action;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.Navigator;
import com.alibaba.citrus.turbine.dataresolver.FormGroup;
import com.ulife.item.manager.ItemManager;
import com.ulife.item.module.vo.ItemVo;

public class ItemAction {

	private static final Logger log = LoggerFactory.getLogger(ItemAction.class);

	@Autowired
	private ItemManager itemManager;

	public void doAddItem(@FormGroup("additem") ItemVo itemVo, Navigator nav) {
		try {
			itemManager.addItem(itemVo);
		} catch (Exception e) {
			log.error("add item error. " + itemVo, e);
		}

		nav.redirectTo("itemLink").withTarget("itemlist").withParameter("sId", itemVo.getsId().toString());
	}
	
	public void doDelItem(@FormGroup("delitem") ItemVo itemVo, Navigator nav) {
		try {
			itemManager.deleteItem(itemVo);
		} catch (Exception e) {
			log.error("del item error. " + itemVo, e);
		}
		
		nav.redirectTo("itemLink").withTarget("itemlist").withParameter("sId", itemVo.getsId().toString());
	}
}
